﻿#ifndef _UART_INTERFACE_H_
#define _UART_INTERFACE_H_

#include <iostream>
#include <memory>
#include <atomic>
#include <thread>
#include <string>
#include <chrono>
#include <stdexcept>
#include <stdbool.h>
#include "inicpp.h"
#include "fifo.h"
#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPortInfo.h"

class UART
{
public:
    typedef std::shared_ptr<UART> Ptr;
    UART();
    ~UART();
    void RxTxThreadStart();
    void RxTxThreadStop();
    int Receive(uint8_t *data, int count);
    int Transmit(uint8_t *data, int count);

private:
    itas109::CSerialPort m_Csp;
    std::atomic<bool> m_RxTxThreadRunning;
    std::thread m_RxTxThread;
    FIFO<uint8_t> m_RxFifo;
    FIFO<uint8_t> m_TxFifo;
};

#endif /*_UART_INTERFACE_H_*/